/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;


import controle.ControllerCompiler;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author 1
 */
public class JanelaSematico extends javax.swing.JFrame {

    /**
     * Creates new form JanelaAlterarExcluirUsuario
     */
    private JTable tabela;
    private DefaultTableModel modelo = new DefaultTableModel();
    private ControllerCompiler controller;

    public JanelaSematico(ControllerCompiler controller) {
        initComponents();
        this.controller = controller;
        criarTabela();
        
        //campoBusca.addActionListener(controller);
        //botaoExcluir.addActionListener(controller);
        //botãoAlterar.addActionListener(controller);
        
        rolagem.setViewportView(tabela);
    }

    private void criarTabela() {
       tabela = new JTable(modelo);
      //  tabela.addMouseListener(controller);
        modelo.addColumn("Erros Identificados");//0
       // modelo.addColumn("Estado");//1
        /*modelo.addColumn("IUPAC Name");//2
        modelo.addColumn("Family");//3
        modelo.addColumn("specie");//4
        modelo.addColumn("Type");//5
        modelo.addColumn("HBA");//6
        modelo.addColumn("HBD");//7 
        modelo.addColumn("File");//8
        modelo.addColumn("MWT(Da)");//9
        modelo.addColumn("Molecular Formula");//10
        modelo.addColumn("CLogP");//11       
        modelo.addColumn("Data Inserted");//12
        modelo.addColumn("Data Modification");//13
        modelo.addColumn("Hour");//14*/
        tabela.getColumnModel().getColumn(0).setPreferredWidth(150);
        //tabela.getColumnModel().getColumn(1).setPreferredWidth(100);
        //tabela.getColumnModel().getColumn(2).setPreferredWidth(80);
        /*tabela.getColumnModel().getColumn(3).setPreferredWidth(50);
        tabela.getColumnModel().getColumn(4).setPreferredWidth(50);
        tabela.getColumnModel().getColumn(5).setPreferredWidth(20);
        tabela.getColumnModel().getColumn(6).setPreferredWidth(10);
        tabela.getColumnModel().getColumn(7).setPreferredWidth(10);
        tabela.getColumnModel().getColumn(8).setPreferredWidth(80);
        tabela.getColumnModel().getColumn(9).setPreferredWidth(10);
        tabela.getColumnModel().getColumn(10).setPreferredWidth(20);
        tabela.getColumnModel().getColumn(11).setPreferredWidth(10);
        tabela.getColumnModel().getColumn(12).setPreferredWidth(20);
        tabela.getColumnModel().getColumn(13).setPreferredWidth(20);
        tabela.getColumnModel().getColumn(14).setPreferredWidth(20);*/
    }
    
     public void preencherTabela(String erro) {

        //ResultSet rs = res;
        //modelo.setNumRows(0);
        Object[] obj = new Object[1];
        obj[0]=erro;
        
        //try {
            //rs.next();
                       
          //  do {
        
                /*obj[0] = rs.getObject("Codigo");
                obj[1] = rs.getObject("Nome");
                obj[2] = rs.getObject("Nome_iupac");*/
                /*obj[3] = rs.getObject("Familia");
                obj[4] = rs.getObject("Especie");
                obj[5] = rs.getObject("Tipo");
                obj[6] = rs.getObject("HBA");
                obj[7] = rs.getObject("HBD");
                obj[8] = rs.getObject("Localizacao_arquivo");
                obj[9] = rs.getObject("Peso_molecular");
                obj[10] = rs.getObject("Formula_molecular");
                obj[11] = rs.getObject("Logp");
                obj[12] = rs.getObject("Data");
                obj[13] = rs.getObject("Datamod");
                obj[14] = rs.getObject("Hora");
                */
                modelo.addRow(obj);
            //} while (rs.next());

        //} catch (SQLException ex) {
          //  JOptionPane.showMessageDialog(null, "Nenhuma molécula cadastrada no banco!");
        //}
     }

    

   

   /* public JTextField getCampoBusca() {
        return campoBusca;
    }*/
    
    public JTable getTable(){
    return tabela;
    }
    


    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        rolagem = new javax.swing.JScrollPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(".:: Erros identificados::.");

        mainPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Listagem de Tokens", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rolagem, javax.swing.GroupLayout.DEFAULT_SIZE, 680, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rolagem, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(70, 70, 70))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel mainPanel;
    private javax.swing.JScrollPane rolagem;
    // End of variables declaration//GEN-END:variables
}
